#ifndef TCPCLIENT_H
#define TCPCLIENT_H

#include <QTcpSocket>
#include <QMainWindow>
#include <QTimer>

class QString;
class QLineEdit;
class QPushButton;
class QTextEdit;
class QLabel;
class QCheckBox;

class TcpClient : public QMainWindow
{
    Q_OBJECT
public:
    TcpClient();
    virtual ~TcpClient();

    void sendRequest(const QString& request);
    void stopSend();
    void connectionClosedByServer();
    QVector<QString>& getParseData();
    void setSendAreaText(const QString& text);
    void setMsgFrames(QStringList slmsgs);
signals:
    void ParseFinished();
    void AssembleMessage();
private slots:
    void connecttoServer();
    void error(QAbstractSocket::SocketError);
    void successed();
    void autosend(int);
    void timerHander();
    void sendonce();
    void intervalValHandler(const QString&);
    void DbMsgsend(int);
private:
    void customUI();

    QTcpSocket tcpSocket;
    QLineEdit* IpEdit;
    QPushButton* connectbtn;
    QPushButton* sendbtn;
    QPushButton* cleanTextEditBtn;
    QTextEdit* sendareaEdit;
    QLineEdit* intervalEdit;
    QLabel* linkstatusLab;
    QLabel* sendstatusLab;
    QCheckBox* autosendBox;
    QCheckBox* sendDbMsgBox;
    QWidget* widget;
    QTimer* timer;

    QPushButton* parsebtn;
    QPushButton* assemblebtn;
    QVector<QString> vetParseDat;
    QStringList slMsgFrames;
    int curCount;
};

#endif // TCPCLIENT_H
